package com.shwread.android.ui.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;


/**
 * 监听局根布变化的线性布局
 * 
 * @author zouqp
 *         2015-03-02
 */

public class ListenSoftInputMethodLinearLayout
        extends
        LinearLayout
{
	private OnSoftInputMethodListener mListener;
	
	public interface OnSoftInputMethodListener
	{
		void OnSoftInputMethodChanged(boolean isShow);
	}
	
	public void setOnSoftInputMethodListener(OnSoftInputMethodListener l) {
		mListener = l;
	}
	
	public ListenSoftInputMethodLinearLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	
	@Override
	protected void onSizeChanged(int w, int h, int oldw, int oldh) {
		super.onSizeChanged(w, h, oldw, oldh);
		
		if (mListener != null)
		{
			boolean isShow ;
			if(oldh - h > 100 ) {//为了适应有些手机的底部有三个软系统键
				isShow = true;
			} else {
				isShow = false;
			}
			mListener.OnSoftInputMethodChanged(isShow);
		}
	}
}
